//
//  SignLabelViewController.m
//  MemberProject
//
//  Created by vincent luo on 15/4/19.
//  Copyright (c) 2015年 MAC OS X. All rights reserved.
//

#import "SignLabelViewController.h"


#define widthDistance 5
#define heightDsitance 2
#define labelBtnWidth 50
#define labelBtnHeight 25
@interface SignLabelViewController ()
{
    NSArray *totalArr;
    
}
@end

@implementation SignLabelViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setupData];
    [self setupView];
}
-(void)setupData
{
    totalArr = @[@"扶贫济困",@"助老助残",@"社区服务",@"生态建设",@"大型活动",@"抢险救灾",@"网络文明",@"社会管理",@"文化建设",@"西部开发",@"海外服务"];
}
-(void)viewWillDisappear:(BOOL)animated
{
    self.bBlock(self.selectArr);
}
-(void)setupView
{
    self.title = @"意向服务领域";
    [self setExtraCellLineHidden:self.mainTableView];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return totalArr.count;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *str = totalArr[indexPath.row];
    if ([self.selectArr containsObject:str]) {
        [self.selectArr removeObject:str];
        
    }else
    {
        [self.selectArr addObject:str];
    }
    [self.mainTableView reloadData];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellStr"];
    if (cell==nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cellStr"];
    }
    NSString *contentStr =totalArr[indexPath.row];
    if ([self.selectArr containsObject:contentStr]) {
        cell.detailTextLabel.text = @"已选";
    }else
    {
        cell.detailTextLabel.text = @"";
    }
    cell.textLabel.text = contentStr;
    
    
    return cell;
}
-(void)backAction:(backBlock)block
{
    self.bBlock = block;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
